﻿using FluentFTP;

namespace Digitalmes.Infrastructure.Ftp;

/// <summary>
/// FTP 客户端接口。
/// </summary>
public interface IFluentFtpClient : IAsyncDisposable
{
    /// <summary>
    /// FTP 客户端。
    /// </summary>
    IAsyncFtpClient Client { get; }

    /// <summary>
    /// 上传本地文件到远程服务器。
    /// </summary>
    /// <param name="localPath">要上传的本地文件。</param>
    /// <param name="remotePath">远程服务器文件。</param>
    /// <param name="isOverwrite">若远程服务器文件存在时，是否覆盖。</param>
    /// <param name="createRemoteDir">若远程服务器目录不存在时，是否创建目录。</param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task<bool> UploadFileAsync(string localPath, string remotePath, bool isOverwrite = true, bool createRemoteDir = false, CancellationToken cancellationToken = default);

    /// <summary>
    /// 从远程服务器下载文件。
    /// </summary>
    /// <param name="localPath">下载的本地文件。</param>
    /// <param name="remotePath">要下载的远程服务器文件。</param>
    /// <param name="isOverwrite">若远程服务器文件存在时，是否覆盖。</param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task<bool> DownloadFileAsync(string localPath, string remotePath, bool isOverwrite = true, CancellationToken cancellationToken = default);

    /// <summary>
    /// 删除远程文件。
    /// </summary>
    /// <param name="remotePath">要删除的远程服务器文件。</param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task<bool> DeleteFileAsync(string remotePath, CancellationToken cancellationToken = default);
}
